package com.itheima.web;

import com.itheima.daomain.User;
import com.itheima.service.updateServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Descriptionn:test
 * @Create by:依然
 * @Date:2021/11/3 11:09
 */
@WebServlet("/queryUserById")
public class queryUserById extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        updateServlet updateServlet = new updateServlet();
        String id = request.getParameter("id");
        User user = updateServlet.update(Integer.parseInt(id));
        System.out.println("获取到的ID:" + id);
        request.setAttribute("users", user);
        request.getRequestDispatcher("/update.jsp").forward(request, response);
    }
}
